package stream;

/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/5/4
 * //1. 第一个队伍只要名字为3个字的成员姓名；
 * //2. 第一个队伍筛选之后只要前3个人；
 * //3. 第二个队伍只要姓张的成员姓名；
 * //4. 第二个队伍筛选之后不要前2个人；
 * //5. 将两个队伍合并为一个队伍；
 * //6. 根据姓名创建`Person`对象；
 * //7. 打印整个队伍的Person对象信息。
 */
import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Stream;
class Person {
    private String name;

    public Person(String name) {
        this.name = name;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }


    @Override
    public String toString() {
        return "Person{name='" + name + "'}";
    }
}
public class StreamDemo {
    public static void main(String[] args) {
        ArrayList<String> list1 = new ArrayList<>();
        Collections.addAll(list1, "张无忌","张强", "张三丰", "赵六", "周七七", "吴八","胡可可" );
        ArrayList<String> list2 = new ArrayList<>();
        Collections.addAll(list2, "张三丰","李四","张无忌","钱七","张帅" );
        Stream<String> newList1= list1.stream()
                .filter(name -> name.length() == 3)
                .limit(3);
        Stream<String> newList2=list2.stream()
                .filter(name -> name.startsWith("张"))
                .skip(2);
        Stream.concat(newList1, newList2)
                .map(name -> new Person(name))
                .forEach(person -> {
                    System.out.println( person);
                });


    }
}
